import { request } from "./request";

// 获取所有分类列表（不分页）
export function getAllCategories() {
  return request({
    url: "/category/list",
    method: "get",
    params: { page: 1, size: 1000 }, // 获取足够多的数据
  });
}

// 删除分类
export function deleteCategory(id) {
  return request({
    url: `/category/${id}`,
    method: "delete",
  });
}

// 批量删除分类
export function batchDeleteCategory(ids) {
  return request({
    url: `/category/batch/${ids}`,
    method: "delete",
  });
}

// 删除子分类
export function deleteSubCategory(id) {
  return request({
    url: `/category/sub/${id}`,
    method: "delete",
  });
}

// 批量删除子分类
export function batchDeleteSubCategory(ids) {
  return request({
    url: `/category/sub/batch/${ids}`,
    method: "delete",
  });
}

// 修改分类
export function updateCategory(data) {
  return request({
    url: "/category",
    method: "put",
    data,
  });
}

// 修改子分类
export function updateSubCategory(data) {
  return request({
    url: "/category/sub",
    method: "put",
    data,
  });
}

// 获取分类列表
export function getCategoryList(params) {
  return request({
    url: "/category/list",
    method: "get",
    params,
  });
}

// 新增分类
export function addCategory(data) {
  return request({
    url: "/category",
    method: "post",
    data,
  });
}

// 新增子分类
export function addSubCategory(data) {
  return request({
    url: "/category/sub",
    method: "post",
    data,
  });
}
